#include "File.h"

/*
==============================
Returns file lenght
==============================
*/
int File::filelength( FILE *f )
{
	int pos;
	int end;

	pos = ftell( f );
	fseek ( f, 0, SEEK_END );
	end = ftell( f );
	fseek( f, pos, SEEK_SET );

	return end;
}

/*
=============================
Creates any directory needed to store the given filename
=============================
*/
void File::create_path( char *path )
{
	char *ofs;

	for ( ofs = path+1; *ofs; ofs++ )
	{
		if ( *ofs == '/' )
		{
			// create the directory
			*ofs = 0;
			mkdir( path );
			*ofs = '/';
		}
	}
}

/*
=============================
Close file
=============================
*/
void File::close_file( FILE *f )
{
	fclose( f );
}

/*
=============================
Finds the file in the search path.
Returns filesize and a open FILE *.
=============================
*/
void File::open_file( char *filename, FILE **f )
{
}
